#include "DXUT.h"

#include "Cavemap.h"

void Cavemap::init(int seed, int octaves, float delta, float valueLimit, int x, int z) {
	_x = x;
	_z = z;
	ridged.SetSeed(seed);
	ridged.SetOctaveCount(octaves);
	
	Delta		= delta;
	ValueLimit	= valueLimit;
}

Cavemap::Cavemap(int seed, int octaves, float delta, float valueLimit, int x, int z)  {
	init(seed, octaves, delta, valueLimit, x, z);
}

Cavemap::Cavemap(int seed, float delta, float valueLimit, int x, int z)  {
	init(seed, 2, delta, valueLimit, x, z);
}

Cavemap::Cavemap(float delta, float valueLimit, int x, int z)  {
	init(0, 2, delta, valueLimit, x, z);
}

Cavemap::~Cavemap() {

}

float Cavemap::getCave(int x, int z, int y) {
	return ridged.GetValue((x) * Delta, y * Delta, (z) * Delta);
}

bool Cavemap::isCave(int x, int z, int y) {
	return (ridged.GetValue((x) * Delta, y * Delta, (z) * Delta)  > ValueLimit );
}

float Cavemap::getValue(int x, int z, int y) {
	return ridged.GetValue((x + _x) * Delta, y * Delta, (z + _z) * Delta);
}